<#include "header.htm"/>
<#import "../macros/pagination.ftl" as pagination/>
<#import "../macros/presentation.ftl" as presentation/>
<#assign canEditSomeMessage = false/>

<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/jquery.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/jquery.jeditable.pack.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/post.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/pagination.js?${startupTime}"></script>
<#if logged>
	<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/watch.js?${startupTime}"></script>
</#if>
<script type="text/javascript">
var CONTEXTPATH = "${contextPath}";
var SERVLET_EXTENSION  = "${extension}";
</script>
<script type="text/javascript">
<#include "js/karma.js">
<#include "js/utils.js"/>
<#if canRemove || isModerator || isAdmin>
	function confirmDelete(postId)
	{
		if (confirm("${I18n.getMessage("Moderation.ConfirmPostDelete")}")) {
			var reason = prompt("${I18n.getMessage("ModerationLog.changeReason")}");

			if (reason == null || reason == "") {
				alert("${I18n.getMessage("ModerationLog.reasonIsEmpty")}");
				return false;
			}
			else {
				var link = document.getElementById("delete" + postId);
				link.href += "&log_description=" + encodeURIComponent(reason) + "&log_type=1";
			}
			return true;
		}		
		return false;
	}
</#if>
</script>
<#if moderator>
	<script type="text/JavaScript" src="${JForumContext.encodeURL("/js/list/moderation")}"></script>
</#if>
<script type="text/JavaScript">
function sendEmail(s1, s2)
{
	document.location = 'mailto:' + showEmail(s1, s2);
}
function quickReply(index,username){
	 document.getElementById('message').focus();
   if(index!="0"){
         document.getElementById('message').value=
			  document.getElementById('message').value+"回复【"+index+"楼】"+" "+username+" :"+
		      "\n"+"-----------------------------------------------------------------------"+"\n"; 
    }else{
    	 document.getElementById('message').value=
    		  document.getElementById('message').value+"回复【楼主位】"+" "+username+" :"+
    	      "\n"+"-----------------------------------------------------------------------"+"\n";
        }
    document.getElementById('message').focus();
   }
   
function quickReplyQueto(post_id,index,username){
	 document.getElementById('message').focus();
   if(index!="0"){
         document.getElementById('message').value=
			  document.getElementById('message').value+"回复【"+index+"楼】"+" "+username+" :"+
		      "\n"; 
    }else{
    	 document.getElementById('message').value=
    		  document.getElementById('message').value+"回复【楼主位】"+" "+username+" :"+
    	      "\n";
        }
    var maxLength=500;
    
    var str=document.getElementById(post_id).innerHTML.replace(/<(.+?)>/igm,"").replace(/<\/(.+?)>/igm,"").replace(/\n\n\n/igm,"\n").replace(/\n\n/igm,"\n").replace(/&nbsp;/igm," ")
    str=(str.length>maxLength)?(str.substring(0,maxLength)+"\n......"):str;
    document.getElementById('message').value=document.getElementById('message').value+str+"\n-----------------------------------------------------------------------\n";
    document.getElementById('message').focus();
    
   }

</script>

<table style="margin-top:15px;" width="100%">
      <tr >
        <td valign="middle" align="left" width="50">
				<a href="${JForumContext.encodeURL("/jforum${extension}?module=posts&amp;action=insert&amp;forum_id=${forum.id}", "")}" rel="nofollow" class="icon_new_topic"><img src="${contextPath}/images/transp.gif" alt="" /></a>
		</td>
		<td width="50" align="left" valign="middle" nowrap="nowrap">
					 
			<#if topic.status == STATUS_LOCKED>
				   <span class="icon_reply_locked"><img src="${contextPath}/images/transp.gif" alt="" /></span>
			<#else>
				   <a href="${JForumContext.encodeURL("/posts/reply/${start}/${topic.id}")}" rel="nofollow" class="icon_reply nav"><img src="${contextPath}/images/transp.gif" alt="" /></a>
			</#if>		
		</td>
		<td nowrap="nowrap">
 		  <span class="nav">
			<a  href="${JForumContext.encodeURL("/forums/list")}">${I18n.getMessage("ForumListing.forumIndex")} </a> &raquo; 
		  <#if fromAll?exists>
            <a  href="${JForumContext.encodeURL("/allTopics/list")}">${I18n.getMessage("ForumBase.allForum")} </a> 
          <#else>
           	<a  href="${JForumContext.encodeURL("/forums/show/${forum.id}")}">${forum.name} </a> 
          </#if>  
        </span>
        </td>
         <td  align="right" nowrap="nowrap"><@presentation.forumsComboTable/></td>
 
        </tr>       
</table>

<table width="100%"> 
     <tr>
       <td align="left" valign="middle"> 
       <span class="maintitle"><a href="#" name="top" class="maintitle" id="top">${topic.title?html}</a></span>

       </td>
       <td align="right"  valign="middle"  nowrap="nowrap"><#assign paginationData><@pagination.doPagination "list", topic.id/></#assign>${paginationData}
       </td>
     </tr>
</table>
 
<table class="forumline" cellspacing="0" cellpadding="3" width="100%"  >
				 <#if poll?exists>
					<tr>
						<td class="cathead cattitle" align="center" colspan="2" nowrap="nowrap" width="100%">${I18n.getMessage("PostShow.pollTitle")}</td>
					</tr>
					<tr>
						<td class="row1" colspan="2" align="center">
							<#if (poll.open && canVoteOnPoll && !request.getParameter("viewResults")?exists)>
								<form action="${JForumContext.encodeURL("/jforum")}" method="post">
									<input type="hidden" name="action" value="vote" />
									<input type="hidden" name="module" value="${moduleName}" />
									<input type="hidden" name="poll_id" value="${poll.id}" />
									<input type="hidden" name="topic_id" value="${topic.id}" />
									<div class="poll">
										<span class="strong">${poll.label?html}</span>
										<table class="poll">
										<#list poll.options as option>
											<tr>
												<td><input type="radio" name="poll_option" value="${option.id}">${option.text?html}</input></td>
											</tr>
										</#list>
										</table>
										<input type="submit" value="${I18n.getMessage("PostShow.pollVote")}"></input><br />
										<span class="gensmall" align="center"><a href="${JForumContext.encodeURL("/jforum${extension}?module=posts&amp;action=list&amp;topic_id=${topic.id}&amp;viewResults=true", "")}">${I18n.getMessage("PostShow.showPollResults")}</a></span>
									</div>
								</form>
							<#else>
								<@presentation.renderPoll poll/>
							</#if>
						</td>
					</tr>
				</#if>
						
				<tr>
					<th class="thleft"  nowrap="nowrap" width="17%" height="26">${I18n.getMessage("PostShow.author")}</th>
					<th class="thright" nowrap="nowrap" style="83%" >${I18n.getMessage("PostShow.messageTitle")}</th>
				</tr>

				<!-- POST LISTING --> 
				<#list posts as post>
					<#if post_index % 2 == 0>
					 
						 <#assign rowbg><@presentation.postrow1/></#assign>
					<#else>
						 
						 <#assign rowbg><@presentation.postrow2/></#assign>
					</#if>
	
					<#assign user = users.get(post.userId)/>
					<#assign canEditCurrentMessage = (post.canEdit && topic.status != STATUS_LOCKED) || moderatorCanEdit/>
					<tr >
 	 						<#include "post_show_action_buttons_inc.htm"/> 
 					</tr>

					<tr>
						<!-- Username -->
						<#assign rowspan = "3"/>
						<#assign useSignature = (user.attachSignatureEnabled && user.signature?exists && user.signature?length > 0 && post.isSignatureEnabled())/>

						<#if useSignature>
							<#assign rowspan = "3"/>
						<#else>
							<#assign rowspan = "2"/>
						</#if>

						<td   bgcolor="${rowbg}" class="postUserMeta" valign="top" align="left"  rowspan="${rowspan}"   >
							<#include "post_show_user_inc.htm"/>
						</td>
		
						<!-- Message -->
						<td  bgcolor="${rowbg}" valign="top" id="post_text_${post.id}">
							<span class="postbody" id="post_body_${post.id}" >
									<div class="edit_area" id="${post.id}">${post.text}</div>
							</span>
                             <br><br> 
							<!-- Attachments -->
							<#if post.hasAttachments() && (canDownloadAttachments || attachmentsEnabled)>
								<#assign attachments = am.getAttachments(post.id, post.forumId)/>
                               <span>
                              
								<#include "post_show_attachments_inc.htm"/>
								
								</span>

							</#if>
								
							<#if (post.editCount > 0) && post.editTime?exists>
								<#if post.editCount == 1>
									<#assign editCountMessage = "PostShow.editCountSingle"/>
								<#else>
									<#assign editCountMessage = "PostShow.editCountMany"/>
								</#if>
								
							<p><i><span class="gensmall" >${I18n.getMessage(editCountMessage, [post.editCount, post.editTime?datetime?string])}</span></i></p>
							</#if>
						</td>
					</tr>

					<#if useSignature>
						<tr>
							<td    bgcolor="${rowbg}" valign="bottom" width="100%"  >
				              <hr> 
                              <span class="gensmall">  ${user.signature}</span>
							</td>
						</tr>
					</#if>
		
					<tr> 
						<td  bgcolor="${rowbg}" valign="bottom" nowrap="nowrap"   width="100%">
							<#include "post_show_user_profile_inc.htm"/>					
						</td>
						
					</tr>
					
				</#list> 
				<!-- END OF POST LISTING -->
		        
				<tr align="center">
					<td class="catbottom" colspan="2" height="28">
						<table cellspacing="0" cellpadding="0" border="0">
							<tr>
								<td align="center"><span class="gensmall">&nbsp;</span></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<a href="#" id="bottom"></a>
			
			<table cellspacing="2" cellpadding="2" width="100%" align="center" border="0">
				<tr>
					<td valign="middle" align="left" width="50">
						<a href="${JForumContext.encodeURL("/jforum${extension}?module=posts&amp;action=insert&amp;forum_id=${forum.id}", "")}" rel="nofollow" class="icon_new_topic"><img src="${contextPath}/images/transp.gif" alt="" /></a>
					</td>	
							
					<#if !readonly>
					<td width="8%" align="left"  nowrap="nowrap">
					</#if>
					<#if topic.status == STATUS_LOCKED>
						<span class="icon_reply_locked"><img src="${contextPath}/images/transp.gif" alt="" /></span>
					<#else>
						<#if !readonly>
							<a href="${JForumContext.encodeURL("/posts/reply/${start}/${topic.id}")}" rel="nofollow" class="icon_reply nav"><img src="${contextPath}/images/transp.gif" alt="" /></a>
						<#else>
							<#assign colspan = "2"/>
						</#if>
		  			</#if>
					</td>
					<td valign="middle" align="right">${paginationData}</td>
				</tr>
			</table>
			
			<table width="100%" align="center">
				
				<#if (logged || anonymousPosts) && topic.status != STATUS_LOCKED && !readonly>
					<tr>
						<td colspan="3">
					<script type="text/javascript">
					
					function newCaptcha()
					{
						document.getElementById("captcha_img").src = "${contextPath}/jforum${extension}?module=captcha&action=generate&timestamp=" + new Date().getTime();
					}
	
					function validatePostForm(f)
					{
						if (f.message.value.replace(/^\s*|\s*$/g, "").length == 0) {
							alert("${I18n.getMessage("PostForm.textEmpty")}");
							f.message.focus();
						
							return false;
						}				
						$("#icon_saving").css("display", "inline");
						$("#btnSubmit").attr("disabled", "disabled").val("${I18n.getMessage("PostForm.saving")}...");
					
						return true;
					}
				
					</script>

			
					<form action="${JForumContext.encodeURL("/jforum")}" method="post" name="post" id="post" onsubmit="return validatePostForm(this);" enctype="multipart/form-data" accept-charset="${encoding}">
						<input type="hidden" name="action" value="insertSave" />
						<input type="hidden" name="module" value="posts" />
						<input type="hidden" name="forum_id" value="${forum.id}" />
						<input type="hidden" name="start" value="${start?default("")}" />
						<input type="hidden" name="topic_id" value="${topic.id}" />
						<input type="hidden" name="disable_html" value="1" />
						<input type="hidden" name="quick" value="1" />
                       <#if fromAll?exists>
                        <input type="hidden" name="fromAll" value="0" />
                       </#if>

						   <table width="83%" align="right">
						       <tr>
								<td align="center" >
									<img src="${contextPath}/templates/${templateName}/images/icon_mini_message.gif" align="middle" alt="Message" />
									<span class="nav">${I18n.getMessage("PostForm.quickReply")}</span>
								</td>
							   </tr>
							   
								<tr>
	
									<td align="center">
								        <textarea class="post"   name="message" id="message" rows="10" cols="60" ></textarea>
										
									</td>
								</tr>
								<#if needCaptcha?default(false)>
									<tr>
										<td>
											<img border="0" align="middle" id="captcha_img"/>
											<br />
											<span class="gensmall">${I18n.getMessage("User.captchaResponse")}</span>
											<input type="text" class="post" style="width: 80px; font-weight: bold;" maxlength="50" name="captcha_anwser" /> 
											<br />
											<span class="gensmall">${I18n.getMessage("User.hardCaptchaPart1")} <a href="#newCaptcha" onClick="newCaptcha()"><b>${I18n.getMessage("User.hardCaptchaPart2")}</b></a></span>
										</td>
									</tr>
								</#if>
								<tr>
									<td align="center" >										
										<input type="submit" id="btnSubmit"  value="${I18n.getMessage("PostForm.submit")}"  />
									    <img src="${contextPath}/images/transp.gif" id="icon_saving">

									</td>
								</tr>
						   </table>
						 
		              	 </form>
					

						</td>
					</tr>
				</#if>
				
				<#if isModerator || isAdmin>
					<form action="${JForumContext.encodeURL("/jforum")}" method="post" name="formModeration" id="formModeration">
					<input type="hidden" name="action" value="doModeration" />
					<input type="hidden" name="module" value="moderation" />
					<input type="hidden" name="returnUrl" value="${JForumContext.encodeURL("/${moduleName}/${action}/${start}/${topic.id}")}" />
					<input type="hidden" name="forum_id" value="${topic.forumId}" />
					<input type="hidden" name="topic_id" value="${topic.id}" />
					<input type="hidden" name="log_type" value="0"/>
					<input type="hidden" name="log_description">
					<input type="hidden" id="moderationTodo" />

					</form>
				</#if>
			</table>

			<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tr>
					<td align="left" valign="top" class="gensmall">
						<#if logged>
							<#if bookmarksEnabled>
								<a href="javascript:addBookmark(2, ${topic.id});"><img src="${contextPath}/templates/${templateName}/images/icon_bookmark.gif" align="middle"  alt="XML" />&nbsp;${I18n.getMessage("Bookmarks.addTo")}</a>
								<br>
							</#if>
						</#if>
					</td>
					<td align="right"><@presentation.forumsComboTable/></td>
				</tr>
			</table>
 

<a name="quick"></a>
<#include "bottom.htm"/>